package io.renren.modules.api.service.impl;

import io.renren.modules.api.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import io.renren.modules.api.dao.UserCouponsDao;
import io.renren.modules.api.entity.UserCouponsEntity;
import io.renren.modules.api.service.UserCouponsService;



@Service("userCouponsService")
public class UserCouponsServiceImpl implements UserCouponsService {
	@Autowired
	private UserCouponsDao userCouponsDao;
	
	@Override
	public UserCouponsEntity queryObject(Long id){
		return userCouponsDao.queryObject(id);
	}
	
	@Override
	public List<UserCouponsEntity> queryList(Map<String, Object> map){
		return userCouponsDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return userCouponsDao.queryTotal(map);
	}
	
	@Override
	public void save(UserCouponsEntity userCoupons){
		userCouponsDao.save(userCoupons);
	}
	
	@Override
	public void update(UserCouponsEntity userCoupons){
		userCouponsDao.update(userCoupons);
	}
	
	@Override
	public void delete(Long id){
		userCouponsDao.delete(id);
	}
	
	@Override
	public void deleteBatch(Long[] ids){
		userCouponsDao.deleteBatch(ids);
	}

	@Override
	public boolean isUserHaveCoupon(UserEntity user, Long couponid) {
		UserCouponsEntity userCouponsEntity = userCouponsDao.queryObjectByUserIdCid(user.getUserId(),couponid);
		if (userCouponsEntity != null) {
			return true;
		}

		return false;
	}

	@Override
	public UserCouponsEntity queryObjectByUserIdAndCouponId(Long userId, Long couponid) {
		return userCouponsDao.queryObjectByUserIdCid(userId,couponid);
	}

}
